/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dsproject;

import dsproject.Simulator.TYPE;

/**
 *
 * @author jkf2
 */
public class Report {

    private int bandwidthUsed;
    private int nbOfMessage;
    private int nbOfLoop;
    //Because the implementation wait for all request to be achieved, the effective number of loop may be bigger than the parametized value
    private int effectiveNBOfLoop;
    private int nbOfRequest;
    private Simulator.TYPE type;

    public Report(Simulator.TYPE type, int bandwidthUsed, int nbOfMessage, int nbOfLoop, int effectiveNBOfLoop, int nbOfRequest) {
        this.bandwidthUsed = bandwidthUsed;
        this.nbOfMessage = nbOfMessage;
        this.nbOfLoop = nbOfLoop;
        this.effectiveNBOfLoop = effectiveNBOfLoop;
        this.nbOfRequest = nbOfRequest;
        this.type = type;
    }

    @Override
    public String toString() {
        String report = "\n***Report***\nType: " + type.toString() + "\n";
        report += "Total Bandwidth: " + bandwidthUsed + "\n";
        report += "Nb message exchanged: " + nbOfMessage + "\n";
        report += "Average Nb of Message/Request: " + nbOfMessage / nbOfRequest + "\n";
        report += "Average Size of Message: " + bandwidthUsed / nbOfMessage + "\n";
        report += "Number of Loop: " + nbOfLoop + "\n";
        report += "Effective number of Loop: " + effectiveNBOfLoop;

        return report;
    }

    public String compare(Report rep) {
        String report = "\n***Report***\nComparison: " + this.type.toString() + "/" + rep.getType().toString() + " in ratio scale\n";
        report += "Total Bandwidth : " + (float)bandwidthUsed/rep.getBandwidthUsed() + "\n";
        report += "Messages exchanged: " + (float)nbOfMessage/rep.getNbOfMessage() + "\n";
        report += "Message/Request: " + (float)(nbOfMessage / nbOfRequest)/(rep.getNbOfMessage()/rep.getNbOfRequest()) + "\n";
        report += "Size of Message: " + (float)(bandwidthUsed / nbOfMessage)/(rep.getBandwidthUsed()/rep.getNbOfMessage()) + "\n";
        report += "Effective Loop number: " + (float)effectiveNBOfLoop/rep.getEffectiveNBOfLoop();

        return report;
    }
    public int getBandwidthUsed() {
        return bandwidthUsed;
    }

    public int getEffectiveNBOfLoop() {
        return effectiveNBOfLoop;
    }

    public int getNbOfLoop() {
        return nbOfLoop;
    }

    public int getNbOfMessage() {
        return nbOfMessage;
    }

    public int getNbOfRequest() {
        return nbOfRequest;
    }

    public TYPE getType() {
        return type;
    }

}
